import pymysql
pymysql.install_as_MySQLdb()

import tushare as ts
from sqlalchemy import create_engine

pro = ts.pro_api('09640b7c249de22f51c81fa10ebadcc2c31924864746e333e5ffbe2c')

engine = create_engine('mysql://root:root@127.0.0.1/gupiao?charset=utf8mb4')


df = pro.index_basic(market='SSE')
print(df.shape[0])
res = df.to_sql('index_basic', engine, index=False, if_exists='append', chunksize=5000)

df = pro.index_basic(market='SZSE')
print(df.shape[0])
res = df.to_sql('index_basic', engine, index=False, if_exists='append', chunksize=5000)

df = pro.index_basic(market='CSI')
print(df.shape[0])
res = df.to_sql('index_basic', engine, index=False, if_exists='append', chunksize=5000)
